<template>
  <div id="app">
    <h2>测试题</h2>
    <SubjectItem @result="flag1 = $event"></SubjectItem>
    <SubjectItem @result="flag2 = $event"></SubjectItem>
    <SubjectItem @result="flag3 = $event"></SubjectItem>
    <SubjectItem @result="flag4 = $event"></SubjectItem>
    <SubjectItem @result="flag5 = $event"></SubjectItem>
    <div>
      <FlagItem :list="list"></FlagItem>
    </div>
  </div>
</template>

<script>
import SubjectItem from './components/SubjectItem.vue'
import FlagItem from './components/FlagItem.vue'
export default {
  components: {
    SubjectItem,
    FlagItem
  },
  data() {
    return {
      flag1: '',
      flag2: '',
      flag3: '',
      flag4: '',
      flag5: '',
      list: [this.flag1, this.flag2, this.flag3, this.flag4, this.flag5]
    }
  },
  watch: {
    flag1(newValue) {
      this.list = [newValue, this.flag2, this.flag3, this.flag4, this.flag5]
    },
    flag2(newValue) {
      this.list = [this.flag1, newValue, this.flag3, this.flag4, this.flag5]
    },
    flag3(newValue) {
      this.list = [this.flag1, this.flag2, newValue, this.flag4, this.flag5]
    },
    flag4(newValue) {
      this.list = [this.flag1, this.flag2, this.flag3, newValue, this.flag5]
    },
    flag5(newValue) {
      this.list = [this.flag1, this.flag2, this.flag3, this.flag4, newValue]
    }
  }
}
</script>

<style>
body {
  background-color: #eee;
}

#app {
  background-color: #fff;
  width: 500px;
  margin: 50px auto;
  box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.5);
  padding: 2em;
}
</style>
